USE EstudiosComerciales
go
IF OBJECT_ID('dbo.WASP_D0006_TRANF_TABLE_PENPF000') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.WASP_D0006_TRANF_TABLE_PENPF000
    IF OBJECT_ID('dbo.WASP_D0006_TRANF_TABLE_PENPF000') IS NOT NULL
        PRINT '<<< FAILED DROPPING PROCEDURE dbo.WASP_D0006_TRANF_TABLE_PENPF000 >>>'
    ELSE
        PRINT '<<< DROPPED PROCEDURE dbo.WASP_D0006_TRANF_TABLE_PENPF000 >>>'
END
go
SET ANSI_NULLS ON
go
SET QUOTED_IDENTIFIER ON
go
CREATE PROCEDURE WASP_D0006_TRANF_TABLE_PENPF000
AS

if exists (select * from dbo.sysobjects where id = object_id(N'[sql].[PENPF000]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [sql].[PENPF000]

CREATE TABLE [sql].[PENPF000] (
	[RUTTRABAJA] [decimal](8, 0) NULL ,
	[CODAGENCIA] [smallint] NOT NULL ,
	[CLVEMPRESA] [varchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[CAJPREVTRA] [smallint] NULL ,
	[CIVILPEN] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[CIUDADPEN] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[REGIONPEN] [smallint] NULL ,
	[POSTALPEN] [char] (7) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[TLFONOPEN] [char] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[IDENTIPAG] [char] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[TIPODEPEN] [smallint] NULL ,
	[GLOSDEPEN] [int] NULL ,
	[FVECTOPAG] [decimal](8, 0) NULL ,
	[RENTATRABA] [int] NULL ,
	[MONEDAPEN] [smallint] NULL ,
	[AGINGRESO] [smallint] NULL ,
	[FCONTTRABA] [decimal](8, 0) NULL ,
	[FINGRTRABA] [decimal](8, 0) NULL ,
	[FDESATRABA] [decimal](8, 0) NULL ,
	[FCAMBEMTRA] [decimal](8, 0) NULL ,
	[FCESATRABA] [decimal](8, 0) NULL ,
	[CCAFANT] [smallint] NULL ,
	[ENTIDANTE] [int] NULL ,
	[EJECUTIVO] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[ESTADOTRAB] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[STSCESTRAB] [int] NULL ,
	[STSCSOTRAB] [int] NULL ,
	[FECREAREG] [int] NULL ,
	[USCREAREG] [int] NULL ,
	[RSTFILLER] [int] NULL ,
	[FMODIFREG] [int] NULL ,
	[STSMODREG] [int] NULL ,
	[USRMODREG] [int] NULL ,
	[CTABT] [decimal](9, 0) NULL 
) ON [PRIMARY]

Insert into sql.PENPF000 
select
	RUTTRABAJA,
	CODAGENCIA,
	CLVEMPRESA,
	CAJPREVTRA,
	CIVILPEN,
	CIUDADPEN,
	REGIONPEN,
	POSTALPEN,
	TLFONOPEN,
	IDENTIPAG
	TIPODEPEN,
	GLOSDEPEN,
	RENTATRABA,
	MONEDAPEN,
	FCONTTRABA,
	FINGRTRABA,
	FDESATRABA,
	FCESATRABA,
	CCAFANT,
	ENTIDANTE,
	EJECUTIVO,
	ESTADOTRAB,
	STSCSOTRAB,
	RSTFILLER,
	FMODIFREG,
	STSMODREG,
	USRMODREG,
	CTABT,
	FVECTOPAC,
	AGEINGRES0,
	FCANBEMTRA,
	STSCESTRAN,
	FECREAREC,
	USCREAREC
from [Gestion2].[dbo].[AS_PENPF000]
go
SET ANSI_NULLS OFF
go
SET QUOTED_IDENTIFIER OFF
go
IF OBJECT_ID('dbo.WASP_D0006_TRANF_TABLE_PENPF000') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE dbo.WASP_D0006_TRANF_TABLE_PENPF000 >>>'
ELSE
    PRINT '<<< FAILED CREATING PROCEDURE dbo.WASP_D0006_TRANF_TABLE_PENPF000 >>>'
go
